class MyCart{
    id: Number
    name:String
    price:Number    
    constructor(id:Number,name:String,price:Number){
        this.id=id
        this.name=name
        this.price=price
    }
    getName():String{
         return "当然商品的名称为"+this.name;         
    }
}
const cart2=new MyCart(1,'华为手机',3000)
console.log(cart2.getName());